package BatchOperation;

import java.util.ArrayList;
import java.util.Collections;

/*
* 批操作
* 很多操作会成批的复制或删除元素
* */
public class main {
    public static void main(String[] args) {
        String[] v1=new String[]{"Jason","Tom","Jerry","cat","beef"};
        String[] v2=new String[]{"Jason","Jerry","cat","cow"};
      var arr1=new ArrayList<String>();
      var arr2=new ArrayList<String>();
      //将数组添加到列表中
      Collections.addAll(arr1,v1);
      Collections.addAll(arr2,v2);
      //输出列表
        System.out.println(arr1);
        System.out.println(arr2);
        arr1.removeAll(arr2);
        System.out.println(arr1+"; arr1.removeAll(arr2);//从arr1中删除arr2中出现的所有元素 也就是移除交集");
        arr1.clear();//清除数组
        Collections.addAll(arr1,v1);//将数组还原
        arr1.retainAll(arr2);
        System.out.println(arr1+";arr1.retainAll(arr2); //从arr1中删除未在arr2中出现的元素 也就是保留交集");

    }
}
